package com.ruoyi.slope.video.device.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.slope.video.device.domain.SlopeVideoDevice;
import com.ruoyi.slope.video.device.service.ISlopeVideoDeviceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 视频设备列表Controller
 * 
 * @author ruoyi
 * @date 2025-09-27
 */
@RestController
@RequestMapping("/video.device/device")
public class SlopeVideoDeviceController extends BaseController
{
    @Autowired
    private ISlopeVideoDeviceService slopeVideoDeviceService;

    /**
     * 查询视频设备列表列表
     */
    @PreAuthorize("@ss.hasPermi('video.device:device:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlopeVideoDevice slopeVideoDevice)
    {
        startPage();
        List<SlopeVideoDevice> list = slopeVideoDeviceService.selectSlopeVideoDeviceList(slopeVideoDevice);
        return getDataTable(list);
    }

    /**
     * 导出视频设备列表列表
     */
    @PreAuthorize("@ss.hasPermi('video.device:device:export')")
    @Log(title = "视频设备列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlopeVideoDevice slopeVideoDevice)
    {
        List<SlopeVideoDevice> list = slopeVideoDeviceService.selectSlopeVideoDeviceList(slopeVideoDevice);
        ExcelUtil<SlopeVideoDevice> util = new ExcelUtil<SlopeVideoDevice>(SlopeVideoDevice.class);
        String path = util.exportExcel(response, list, "视频设备列表数据");
    }

    /**
     * 获取视频设备列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('video.device:device:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(slopeVideoDeviceService.selectSlopeVideoDeviceById(id));
    }

    /**
     * 新增视频设备列表
     */
    @PreAuthorize("@ss.hasPermi('video.device:device:add')")
    @Log(title = "视频设备列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlopeVideoDevice slopeVideoDevice)
    {
        return toAjax(slopeVideoDeviceService.insertSlopeVideoDevice(slopeVideoDevice));
    }

    /**
     * 修改视频设备列表
     */
    @PreAuthorize("@ss.hasPermi('video.device:device:edit')")
    @Log(title = "视频设备列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlopeVideoDevice slopeVideoDevice)
    {
        return toAjax(slopeVideoDeviceService.updateSlopeVideoDevice(slopeVideoDevice));
    }

    /**
     * 删除视频设备列表
     */
    @PreAuthorize("@ss.hasPermi('video.device:device:remove')")
    @Log(title = "视频设备列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(slopeVideoDeviceService.deleteSlopeVideoDeviceByIds(ids));
    }
}
